Return to start page
Core/Debug/Library Misc.j
1 library ALibraryCoreDebugMisc requires ALibraryCoreGeneralPlayer
2
3 /**
4 * Displays text on the screen if the debug mode is enabled.
5 * DebugMsg: Your Message - Echoes Your Message to logs//war3erruser.txt
6 * Ursprünglich war es eine Platzhalter-Funktion.
7 * @author Tamino Dauth
8 * @param message The message which will be shown on the screen and if Warcraft is started with Grimore it prints the messag into logs//war3err.txt.
9 */
10 debug function Print takes string message returns nothing
11 debug local integer i
12 debug local player user
13 debug set i = 0
14 debug loop
15 debug exitwhen(i == bj_MAX_PLAYERS)
16 debug set user = Player(i)
17 debug if (IsPlayerPlayingUser(user)) then
18 debug call DisplayTimedTextToPlayer(user, 0.0, 0.0, 999999.0, message)
19 debug endif
20 debug set user = null
21 debug set i = i + 1
22 debug endloop
23 debug call Cheat("DebugMsg: " + message) //JNGP
24 debug endfunction
25
26 /**
27 * Useful for getting the causing struct and instance of the debug message.
28 * Displays the string @param message in the following schema: " - : "
29 * @author Tamino Dauth
30 */
31 //! textmacro A_STRUCT_DEBUG takes STRUCTNAME
32 debug public method print takes string message returns nothing //stub
33 debug call Print($STRUCTNAME$ + " - " + I2S(this) + ": " + message)
34 debug endmethod
35
36 debug private static method staticPrint takes string message returns nothing
37 debug call Print($STRUCTNAME$ + ": " + message)
38 debug endmethod
39 //! endtextmacro
40
41 /**
42 * war3err DumpGlobalHT - prints the names and values of all global variables to logs//war3err.txt
43 * @author Tamino Dauth
44 */
45 debug function PrintGlobals takes nothing returns nothing
46 debug call Cheat("war3err_DumpGlobalHT") //JNGP
47 debug endfunction
48
49 /**
50 * war3err DumpLocalHT - As above, but for the local variables of the current scope
51 * @author Tamino Dauth
52 */
53 debug function PrintLocals takes nothing returns nothing
54 debug call Cheat("war3err_DumpLocalHT") //JNGP
55 debug endfunction
56
57 /**
58 * PauseTracer: If bytecode logging is enabled, this pauses recording
59 * @author Tamino Dauth
60 */
61 debug function PauseBytecodeLogging takes nothing returns nothing
62 debug call Cheat("PauseTracer") //JNGP
63 debug endfunction
64
65 /**
66 * ContinueTracer: If bytecode logging is enabled, this resumes recording
67 * @author Tamino Dauth
68 */
69 debug function ContinueBytecodeLogging takes nothing returns nothing
70 debug call Cheat("ContinueTracer") //JNGP
71 debug endfunction
72
73 /**
74 * When the breakpoint is reached Warcraft 3 is frozen.
75 * @author Tamino Dauth
76 */
77 debug function Breakpoint takes nothing returns nothing
78 debug call Cheat("war3err_Break") //JNGP
79 debug endfunction
80
81 /// @todo Should be private, vJass bug.
82 debug function PrintFunctionError takes string functionName, string message returns nothing
83 debug call Print("Function error in function \"" + functionName + "\": " + message)
84 debug endfunction
85
86 /// @todo Should be private, vJass bug.
87 debug function DebugPlayer takes integer number returns nothing
88 debug if (number < 0 or number >= bj_MAX_PLAYER_SLOTS) then
89 debug call PrintFunctionError("Player", "Invalid parameter number, value " + I2S(number) + ". Setting number to 0 to avoid game crash.")
90 debug set number = 0
91 debug endif
92 //debug return Player(number)
93 debug endfunction
94
95 globals
96 /// @todo Should be private, vJass bug.
97 debug integer gameCacheCounter = 0
98 endglobals
99
100 /// @todo Should be private, vJass bug.
101 debug function DebugInitGameCache takes string campaignFile returns nothing
102 debug if (gameCacheCounter == 256) then
103 debug call PrintFunctionError("InitGameCache", "Reached game cache maximum. Canceling function call.")
104 //debug return null
105 debug endif
106 debug set gameCacheCounter = gameCacheCounter + 1
107 //debug return InitGameCache(campaignFile)
108 debug endfunction
109
110 /// @todo Should be private, vJass bug.
111 debug function DebugDestroyTimer takes timer whichTimer returns nothing
112 //IsTimerPaused
113 //Timer-Ablauf
114 //- Zerstörte Timer laufen trotz ihrer Zerstörung ab. Man muss einen Timer anhalten bevor man ihn zerstört.
115 debug endfunction
116
117 /// @todo Should be private, vJass bug.
118 debug function DebugSetUnitX takes unit whichUnit, real newX returns nothing
119 debug if (newX < GetRectMinX(bj_mapInitialPlayableArea) or newX > GetRectMaxX(bj_mapInitialPlayableArea)) then
120 debug call PrintFunctionError("SetUnitX", "Invalid parameter newX, value " + R2S(newX) + ". Canceling function call to avoid game crash.")
121 //debug return
122 debug endif
123 debug endfunction
124
125 /// @todo Should be private, vJass bug.
126 debug function DebugSetUnitY takes unit whichUnit, real newY returns nothing
127 debug if (newY < GetRectMinY(bj_mapInitialPlayableArea) or newY > GetRectMaxY(bj_mapInitialPlayableArea)) then
128 debug call PrintFunctionError("SetUnitY", "Invalid parameter newY, value " + R2S(newY) + ". Canceling function call to avoid game crash.")
129 //debug return
130 debug endif
131 debug endfunction
132
133 /// @todo Should be private, vJass bug.
134 debug function DebugCreateUnit takes player id, integer unitid, real x, real y, real face returns nothing
135 debug if (x < GetRectMinX(bj_mapInitialPlayableArea) or x > GetRectMaxX(bj_mapInitialPlayableArea) or y < GetRectMinY(bj_mapInitialPlayableArea) or y > GetRectMaxY(bj_mapInitialPlayableArea)) then
136 debug call PrintFunctionError("CreateUnit", "Invalid parameter x or y, values " + R2S(x) + " and " + R2S(y) + ". Canceling function call to avoid game crash.")
137 //debug return null
138 debug endif
139 //debug return CreateUnit(id, unitid, x, y, face)
140 debug endfunction
141
142 /// @todo Should be private, vJass bug.
143 debug function DebugRestoreUnit takes gamecache cache, string missionKey, string key, player forWhichPlayer, real x, real y, real facing returns nothing
144 debug if (not HaveStoredUnit(cache, missionKey, key)) then
145 debug call PrintFunctionError("RestoreUnit", "Stored unit does not exist in game cache. Canceling function call to avoid game crash.")
146 //debug return null
147 debug endif
148 //debug return RestoreUnit(cache, missionKey, key, forWhichPlayer, x, y, facing)
149 debug endfunction
150
151 debug hook Player DebugPlayer
152 debug hook InitGameCache DebugInitGameCache
153 //debug hook DestroyTimer SCOPE_PRIVATEDestroyTimer
154 debug hook SetUnitX DebugSetUnitX
155 debug hook SetUnitY DebugSetUnitY
156 debug hook CreateUnit DebugCreateUnit
157 debug hook RestoreUnit DebugRestoreUnit
158
159 //GroupEnumUnitsInRectCounted und GroupEnumUnitsInRangeCounted
160 //- Die Funktionen GroupEnumUnitsInRectCounted und GroupEnumUnitsInRangeCounted können sich unterschiedlich verhalten, falls sie eine große Anzahl von Einheiten haben.
161 //GetExpiredTimer
162 //- GetExpiredTimer() kann einen Absturtz des Spiels verursachen, wenn es keinen Timer gibt.
163 //Einheitengruppen – vom InWarcraft-Nutzer gexxo
164 //- Werden Einheiten per RemoveUnit() aus dem Spiel entfernt und befinden sich bereits in einer Einheitengruppe, so kann es zu Fehlern kommen, da die erste Einheit der Gruppe nun immer null ist.
165
166 endlibrary
167